#ifndef __BRANCH1_MODEL_PLAYER_H__
#define __BRANCH1_MODEL_PLAYER_H__
#include <daisy\Logic.h>
#include <daisy\OISInputManager.h>
#include <daisy\FrameworkBaseConfig.h>
#include <OGRE\Ogre.h>
#include <OgreNewt.h>
#include <CEGUI\CEGUI.h>
#include "ExtendCamera.h"
#include "MovableObject.h"

class Player:public Branch1::MovableObject,public DAISY::KeyListener
{
	enum AnimaState
	{
		WALK,
		IDLE
	};
public:
	Player(const std::string &name);
	virtual ~Player();
	void doEnable();
	void doDisable();
	void doFrame();
	void doExecute(DAISY::Event * evt);
	bool onKeyPressed(const DAISY::KeyEvent & evt);
	bool onKeyReleased(const DAISY::KeyEvent & evt);
	/*bool onMouseMoved(const DAISY::MouseEvent & evt);
	bool onMousePressed(const DAISY::MouseEvent & evt);
	bool onMouseReleased(const DAISY::MouseEvent & evt);*/
private:
	Ogre::Entity* _entity;
	DAISY::TimeType _interval;
	Ogre::Camera* _camera;
	Ogre::Vector3 _oriCamPit;
	Ogre::Vector3 _oriSigPit;
	Ogre::SceneNode* _cameraNode;
	Ogre::SceneNode* _sightNode;
	Ogre::Real _sigRadius;
	
	bool isForward;
	bool isBack;
	bool isRight;
	bool isLeft;
	int isMove;
	int isRotate;
	bool isSightUp;
	bool isSightDown;
	bool isSightLeft;
	bool isSightRight;
	Real rot_sig_lim;
	Real curr_rot_sig;
	Real _velocity;
	Real _originalVel;
	Real _turbVel;
	Real forwardSpeed;
	Real sideSpeed;

	SdkCameraMan* _cameraMan;
	OgreNewt::Body* bod;//physices body
	OgreNewt::PlayerController* _newtPlayer;
	//CEGUI::WindowManager &wmgr;
	/*OgreNewt::Debugger* debugger;*/
	////
	
	//void showinfo();
	////typedef void (Player::*mfun)();
 //   //std::map<float, mfun> _mapFun;//DAISY::TimeType _timeLine;
	void setCustomForceCallback(OgreNewt::Body* me, float timestep, int threadindex);
	Ogre::AnimationState* _animState;
	AnimaState _robotAniState;
	std::vector<Ogre::Vector3> _posit_dandelions;
	Ogre::Vector3 _targetPosit;
	DAISY::SoundPlayerPtr _sound_collision;
private:
	void findTarget();
	std::string& decode(const CEGUI::String& str);
	Ogre::Vector3 minDistance();
};
class Branch1PlayerFactory: public DAISY::IFactory<DAISY::Actor>
	{
	public:

		virtual const std::string & getTypeName() const;

		virtual pointer_type createInstance(const std::string& instanceName = "BLANK", parameter_type parameter = NULL);
	};
#endif